from django.db import models

# Create your models here.

class Exam(models.Model):
    name = models.CharField(max_length=64)
    description = models.CharField(max_length=64)
    deadline = models.DateTimeField()
    author = models.CharField(max_length=64)

class ExamQuestion(models.Model):
    question = models.CharField(max_length=64)
    exam = models.ForeignKey(Exam)
    point = models.IntegerField()

class ExamAnswer(models.Model):
    answer = models.CharField(max_length=64)
    correct = models.BooleanField()
    question = models.ForeignKey(ExamQuestion)


class StudentExam(models.Model):
    student = models.CharField(max_length=64)
    exam = models.ForeignKey(Exam)
    finished = models.BooleanField()
    grade = models.IntegerField()
    class Meta :
        unique_together = (('student', 'exam'),)

class StudentExamAnswers(models.Model):
    studentAnswer = models.ForeignKey(ExamAnswer)
    studentExam = models.ForeignKey(StudentExam)
    studentQuestion = models.ForeignKey(ExamQuestion)
    class Meta:
        unique_together = (( 'studentExam', 'studentQuestion'))
